import sae

sae.add_vendor_dir('vendor')

#from sae.ext.storage import monkey
#monkey.patch_all()

#from sae.storage import Bucket

#bucket = Bucket('weiphp')

import os

#os.popen("manager.py db init")

import web
from app import app, db
import sae.const
from app import models
from config_user import ROLE_ADMIN


app_chinn = web.database(
    dbn='mysql',
    host=sae.const.MYSQL_HOST,
    port=int(sae.const.MYSQL_PORT),
    user=sae.const.MYSQL_USER,
    passwd=sae.const.MYSQL_PASS,
    db=sae.const.MYSQL_DB
)

#db.drop_all()
db.create_all()
"""
admin = models.Teacher("Admin","13000000000","735828661@qq.com","123456","1","12:00","",1,False,ROLE_ADMIN)
if models.Teacher.query.filter_by(id=admin.id).first() is None:
    db.session.add(admin)
    db.session.commit()
    db.session.close()
"""


#from app import app
#app.debug=True

application = sae.create_wsgi_app(app)